<?php
class Table
{
  protected $tableHeaders;
  protected $tableData;

  public function __construct(array $headers, array $data)
  {
    $this->tableHeaders = $headers;
    $this->tableData = $data;
  }

  /**
   * Table::show()
   *
   * @return
   */
  public function show()
  {
    echo "<table cellpadding=\"0\" cellspacing=\"0\" " .
        "class=\"table-table\">\n";
    $this->showTableHeader();
    $this->showTableData();
    echo "</table>\n";
  }


  /**
   * Table::showTableHeader()
   *
   * Shows the table header.
   *
   * @return
   */
  protected function showTableHeader()
  {
    echo "<tr class=\"table-header\">\n";
    foreach ($this->tableHeaders as $header) {
      echo "<td>$header</td>\n";
    }
    echo "</tr>\n";
  }

  /**
   * Table::showTableData()
   *
   * Shows the data portion of the table.  
   *
   * @return
   */
  protected function showTableData()
  {
    foreach ($this->tableData as $rowNum => $tableRow) {
      $class = (1 & $rowNum) ? 'table-evenrows' : 'table-oddrows';
      echo "<tr class=\"$class\">\n";
      foreach ($tableRow as $cellValue) {
        echo "<td>";
        echo $cellValue;
        echo "</td>\n";
      }
      echo "</tr>\n";
    }
  }

}
?>